package com.devunion.salon.client.common.core;

import com.devunion.salon.client.common.Secured;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * @author spetrakovsky  25.02.2009
 */
public class UserSession implements Serializable {

    /**
     * I hope we can create user session on login for every user.
     */
    private static UserSession currentUserSession = new UserSession();

    private ArrayList<String> userPrivileges = new ArrayList<String>();

    // TODO: replace with UserDTO
    private String userName;

    protected UserSession() {
    }

    public boolean isEnabled(Secured secured) {
        if (secured.getRequiredPrivilege() == null) {
            return true;
        }
        return userPrivileges.contains(secured.getRequiredPrivilege());
    }

    public static UserSession getCurrentUserSession() {
        return currentUserSession;
    }

    public ArrayList<String> getUserPrivileges() {
        return userPrivileges;
    }

    public void setUserPrivileges(ArrayList<String> userPrivileges) {
        this.userPrivileges = userPrivileges;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
}
